home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CUJ9204.ARJ / 1004093A < prev    next >
Text File  |  1992-06-02  |  355b  |  27 lines

  1.  
  2. #include <stdio.h>
  3.  
  4. #define STACK_SIZE 10
  5.  
  6. static node stack[STACK_SIZE];
  7. static size_t stack_ptr = 0;
  8.  
  9. void push(node n)
  10. {
  11.     if (stack_ptr == STACK_SIZE)
  12.         printf("Stack is full\n");
  13.     else
  14.         stack[stack_ptr++] = n;
  15. }
  16.  
  17. node pop(void)
  18. {
  19.     static node error_node = {Error, 0};
  20.  
  21.     if (stack_ptr == 0)
  22.         return error_node;
  23.     else
  24.         return stack[--stack_ptr];
  25. }
  26.  
  27.